﻿@model TestOnlineProject.Models.Entities.Feedback
@using TestOnlineProject.Common
@using TestOnlineProject.Models.Entities
@{
    ViewBag.Title = "Details";
}
@{
    if (!String.IsNullOrEmpty(ViewBag.Msg))
    {
    <script>        alert("@ViewBag.Msg")</script>
    }
}
<script>
    $(document).ready(function () {
        $("#deactivate").click(function () {
        var con = confirm("Are you sure you want to mark as unread this feedback?");
            if (con == true) {
                $.ajax({
                    url: "@Url.Content("~/Feedback/Uncheck")" + "?ids=" + @Model.FeedbackId + "-",
                    type: 'GET',
                    success: function (data) {
                        if (data != null) {
                        alert(data);
                            window.location = "@Url.Content("~/Feedback/Details")" + "?id=" + @Model.FeedbackId;
                        }
                    }
                })
                }
        }); $("#activate").click(function () {
        var con = confirm("Are you sure you want to mark as read this feedback?");
            if (con == true) {
                $.ajax({
                    url: "@Url.Content("~/Feedback/Check")" + "?ids=" + @Model.FeedbackId + "-",
                    type: 'GET',
                    success: function (data) {
                        if (data != null) {
                        alert(data);
                            window.location = "@Url.Content("~/Feedback/Details")" + "?id=" + @Model.FeedbackId;
                        }
                    }
                })
                }
        });
        $("#delete").click(function () {
            var con = confirm("Are you sure you want to delete this feedback?");
            if (con == true) {
                $.ajax({
                    url: "@Url.Content("~/Feedback/Delete")?ids=@Model.FeedbackId" + "-",
                    type: 'GET',
                    success: function (data) {
                        if (data != null) {
                            alert(data);
                            window.location = "@Url.Content("~/Feedback/Index")";
                        }
                    }
                })
            }
        });
    })
</script>
<div class="site_map">
    @Html.ActionLink("Home", "Index", "Home") / @Html.ActionLink("Feedbacks", "Index", "Feedback")
    / <span style="word-wrap: break-word">@Model.Title</span>
</div>
<br />
<div class="main_nav">
    <span><a href="@Url.Content("~/Feedback/Index")">
        <img src="@Url.Content("~/Images/back button.png")" style="height:30px"/>
    </a></span>
</div>
<br />
@{
    if (!Model.IsChecked)
    {
    <div class="alert alert-warning">
        <span>Unread.</span>
    </div>
    }
}
<table class="table table-bordered" style="table-layout: fixed">
    <tr>
        <td style="width: 150px; text-align: right">
            <span>Title</span>
        </td>
        <td>
            <span style="word-wrap: break-word">@Html.DisplayFor(model => model.Title)</span>
        </td>
    </tr>
    <tr>
        <td style="text-align: right">
            <span>Content</span>
        </td>
        <td>
            <span style="word-wrap: break-word">@Html.DisplayFor(model => model.Content)</span>
        </td>
    </tr>
    <tr>
        <td style="text-align: right">
            <span>Sent By</span>
        </td>
        <td>
            @Html.ActionLink(Model.User.FullName, "Index", "Account", new { userId = @Model.UserId }, new { target = "_blank" })
        </td>
    </tr>
    <tr>
        <td style="text-align: right">
            <span>Created Time</span>
        </td>
        <td>
            @Html.DisplayFor(model => model.CreatedTime)
        </td>
    </tr>
    @*<tr>
        <td style="text-align: right">
            <span>Checked</span>
        </td>
        <td>
            @{
                if (Model.IsChecked)
                {
                <span>Yes</span>
                }
                else
                {
                <span>No</span>
                }
            }
        </td>
    </tr>*@
    <tr>
        <td>
        </td>
        <td>
            @{
                if (Model.IsChecked)
                {
                <a href="#" id="deactivate">Mark as unread</a>
                }
                else
                {
                <a href="#" id="activate">Mark as read</a>
                }
                <span>|</span>
            }
            <a href="#" id="delete">Delete</a>
        </td>
    </tr>
</table>
